﻿<?xml version="1.0" encoding="utf-8"?><Articles><Article><ArticlesID>576</ArticlesID><Title>Thủ thuật in tr&amp;#234;n Winform</Title><Body>&amp;lt;p&amp;gt;C&amp;amp;aacute;ch in 1 form qua m&amp;amp;aacute;y in:&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
1. Cho v&amp;amp;agrave;o chương tr&amp;amp;igrave;nh component: Print Document&amp;lt;br /&amp;gt;
2. D&amp;amp;ugrave;ng h&amp;amp;agrave;m mẫu sau:&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
Code:&amp;lt;/p&amp;gt;
&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: csharp;&amp;quot;&amp;gt;
private void printFormToPrinter()
{
PrintDialog printDialog1 = new PrintDialog();
printDialog1.Document = printDocument1;
DialogResult result = printDialog1.ShowDialog();
if ( result == DialogResult.OK )
printDocument1.Print();
}&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;font color=&amp;quot;#0000ff&amp;quot;&amp;gt;&amp;lt;font color=&amp;quot;#000000&amp;quot;&amp;gt;3. Vẽ form khi ra m&amp;amp;aacute;y in:&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
Code:&amp;lt;/font&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: csharp;&amp;quot;&amp;gt;
using System.Drawing.Printing;

private void printDocument1_PrintPage( object sender, PrintPageEventArgs e)
{
Graphics graphic = CreateGraphics();
Image memImage = new Bitmap( Size.Width, Size.Height, graphic );
Graphics memGraphic = Graphics.FromImage( memImage );
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt( dc2, 0, 0, ClientRectangle.Width,
ClientRectangle.Height, dc1, 0, 0, 13369376 );
graphic.ReleaseHdc( dc1 );
memGraphic.ReleaseHdc( dc2 );
e.Graphics.DrawImage( memImage, 0, 0 );
}&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;&amp;amp;nbsp;&amp;lt;/p&amp;gt;</Body><CommentEnabled>True</CommentEnabled><ViewCount>0</ViewCount><ReleaseDate>11/1/2009 12:18:30 AM</ReleaseDate><TotalComment>0</TotalComment><IsMedia>False</IsMedia><IsPicture>False</IsPicture><IsVote>True</IsVote><ArticlePassword /><PostVisible>0</PostVisible><ArticlePath>/2009/11/1/Thu-thuat-in-tren-Winform-240</ArticlePath><Approved>True</Approved><ImagePath /><CategoryId>43</CategoryId><ArrayCatID>43|25</ArrayCatID></Article></Articles>